package com.tdcoding.chat.test;

import io.netty.util.internal.SystemPropertyUtil;

import java.io.File;


public class GenerateProtocolFile {
	/**
	 * 调用protoc.exe生成java数据访问类
	 * */
	public static void main(String[] args) throws Exception {
		File protoPath=new File(SystemPropertyUtil.get("user.dir")+"\\resources\\protobuf\\");
		System.out.println(protoPath.getAbsolutePath());
		for (File protoFile: protoPath.listFiles()) {
			if (protoFile.isDirectory()
					||!protoFile.getName().endsWith(".proto")) {
				continue;
			}
//			String strCmd =protoPath+"protoc.exe --java_out=" + protoFile;
//			int process=Runtime.getRuntime().exec("cmd /c " + strCmd).waitFor();// 通过执行cmd命令调用protoc.exe程序
			String filePath=protoFile.getAbsolutePath().replace("Protocol.proto", ".java");
//			System.out.println("protoc.exe --java_out=./ ./"+protoFile.getName());
//			System.out.println();
			protoFile.renameTo(new File(filePath));
		}
		
	}
}
